# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Andrej Gelenberg <andrej.gelenberg@udo.edu>

pkgname="openbsd-netcat"
pkgver=1.226_1
pkgrel=2
pkgdesc="TCP/IP swiss army knife. OpenBSD variant."
arch=('loong64' 'x86_64')
url="https://salsa.debian.org/debian/netcat-openbsd"
license=('BSD')
depends=('libbsd')
makedepends=('gcc' 'make')
provides=('netcat')
conflicts=('gnu-netcat')
source=("https://salsa.debian.org/debian/netcat-openbsd/-/archive/debian/${pkgver/_/-}/netcat-openbsd-debian-${pkgver/_/-}.tar.gz")
sha256sums=('cd1c102e5954436184c3f7f3e7b649eed05ef38aa9592b55577ca28878b268d2')
b2sums=('a46a357352a9f86fe1f9f1e9d2d17cb6bb16f9c829ffa996711858fd21aed8d54df5834b55850aa2f67ccbcac6c6336379e7553118c8277c4da97278870e87ed')

build() {
  cd netcat-openbsd-debian-${pkgver/_/-}
  for i in `cat debian/patches/series`; do
	echo "** patch $i" 1>&2
	cat "debian/patches/$i"
  done | patch -p1
  make \
	CFLAGS="$CFLAGS -DDEBIAN_VERSION=\"\\\"${pkgver/_/-}\\\"\" -I/usr/include/libbsd" \
	LDFLAGS="$LDFLAGS -lbsd"
}

package() {
  cd netcat-openbsd-debian-${pkgver/_/-}
  install -Dm0755 nc "$pkgdir"/usr/bin/nc
  ln -s nc "$pkgdir"/usr/bin/netcat
  install -Dm0644 nc.1 "$pkgdir"/usr/share/man/man1/nc.1
  install -dm0755 "$pkgdir"/usr/share/licenses/$pkgname/
  head -n28 netcat.c | tail -n+2 >"$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
